﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace GestorDeFlotasDesktop.Facturar
{
    public partial class Facturar : Form
    {
        public Facturar()
        {
            InitializeComponent();

            SqlConnection con = Modelo.Modelo.createConnection();
            SqlDataAdapter da = new SqlDataAdapter(Modelo.SqlQueries.getClientes, con);
            DataSet ds = new DataSet();
            da.Fill(ds);
            cb_cliente.DataSource = ds.Tables[0].DefaultView;
            cb_cliente.DisplayMember = "Cliente";
            cb_cliente.ValueMember = "Id";
            cb_cliente.SelectedIndex = -1;
            Modelo.Modelo.closeConnection(con);
        }

        private void aceptar_Click(object sender, EventArgs e)
        {
            if (!String.IsNullOrEmpty(cb_cliente.Text) && (!String.IsNullOrEmpty(dtp_fin.Text)) && (!String.IsNullOrEmpty(dtp_ini.Text)))
            {
                Login.Login.mainForm.openForm(new Listado_Factura(Convert.ToInt32(cb_cliente.SelectedValue), dtp_ini.Value, dtp_fin.Value));
            }
            else
            {
                MessageBox.Show("Todos los campos son obligatorios");
            }
        }
    }
}
